﻿@{
    Layout = null;
}
@using CNKI.TPI.Web.Search.Model;
<script>
    function searchdb() {
        var startip = $('#startip').val();
        var endip = $('#endip').val();
        if (startip != "" && startip.length != 0) {
            if (!validateIP(startip)) {
                messageAlert('您输入的起始IP格式不正确!');
                return;
            }
        }
        if (endip != "" && endip.length != 0) {
            if (!validateIP(endip)) {
                messageAlert('您输入的终止IP格式不正确!');
                return;
            }
        }

        $($("#ifr")[0].contentWindow.document.body).remove();
        $.ajax({
            type: "GET",
            url: timestamp("@Html.Raw(Url.Action("UserStatisticalSearch", "Admin_Report"))"),
            data: { "searchType": $('#searchType').val(), "startdate": $('#startdate').val(), "enddate": $('#enddate').val(), "startip": startip, "endip": endip },
            beforeSend: function () { $("#loading").show(); },
            success: function (msg) {
                if (msg == "True") {
                    $("#msgtext").html("");
                    //刷新iframe
                    var stype = $("#searchType").val();
                    $("#ifr").attr("src", "../ReportInfo/ShowReport.aspx?RPTPath=@ViewBag.RPTPath&RPTName=@ViewBag.RPTName&SearchType=" + stype).ready();
                }
                else {
                    $("#loading").hide();
                    $("#msgtext").html("该报表暂无数据！");
                }
            },
            error: function (e)
            { $("#loading").hide(); }
        })
    }
    function closeloading() {
        $("#loading").hide();
    }
    $(function () {
        selectTypeChange();
    })
    function selectTypeChange()
    {
        ;
        if ($("#searchType").val() == 1) {
            $("#ipsearch").show();
        }
        else {
            $("#ipsearch").hide();
        }
    }
</script>
<form>
    <div class="wrapR-h" style="margin-top: 20px; padding-bottom: 15px">

        <label class="f-label">统计类型：</label>

        <select id="searchType" name="searchType" class='f-select span2' onchange="selectTypeChange()">
            <option value="0">用户</option>
            <option value="1">IP</option>
        </select>
        <span id="ipsearch">
            IP段：
         <input type="text" class="f-text span2" id="startip">
            至
        <input type="text" class="f-text span2" id="endip">
            </span>
        <br />
        <div style="margin-top: 10px">
            <label class="f-label">统计时间：</label>

            @{
                 string startd  = System.DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd");
                }
            <input type="text" class="f-text span3" id="startdate" readonly="true" value="@startd" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'enddate\')}',dateFmt:'yyyy-MM-dd' })">
            至
              @{
                 string ed  = System.DateTime.Now.ToString("yyyy-MM-dd");
                }
        <input type="text" class="f-text span3" id="enddate" readonly="true" value="@ed" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'startdate\')}',dateFmt:'yyyy-MM-dd' })">
            <input type="button" class="btn btn-m btn-warn-f btn-submit" value="统计" onclick="searchdb();" />

        </div>
        <br />
        <div id="msgtext" style="color: red"></div>
    </div>
    <div>
        <iframe id="ifr" src="../ReportInfo/ShowReport.aspx?RPTPath=@ViewBag.RPTPath&RPTName=@ViewBag.RPTName&SearchType=0" width="930" height="800" style="border: 0px;"></iframe>
    </div>
</form>

